﻿using System;
using System.Linq;
using LINQPad.Extensibility.DataContext;

namespace LINQPad.OpenAccess.UI.ViewModel
{
    /// <summary>
    /// Used to load/write the settings of a view model instance via the LINQPad api.
    /// </summary>
    public interface IPersistableSettingsViewModel<TSettings>
    {
        /// <summary>
        /// Tries to load the view model's settings from the specified sources.
        /// </summary>
        /// <param name="connectionInfo">The connection info.</param>
        /// <param name="source">The source.</param>
        /// <returns>
        ///   <c>true</c> on success; otherwise, <c>false</c>.
        /// </returns>
        bool TryLoadSettingsFrom( IConnectionInfo connectionInfo, TSettings source );
        /// <summary>
        /// Writes the view model's settings to the specified targets.
        /// </summary>
        /// <param name="connectionInfo">The connection info.</param>
        /// <param name="target">The target.</param>
        void WriteSettingsTo( IConnectionInfo connectionInfo, TSettings target );
    }
}
